﻿using System;
using System.Collections.Generic;
using System.Text;

public delegate void CellChangeDelegate(object i_Obj);

public class Cell
{
    private readonly int r_RowIndex;

    public int R_RowIndex
    {
        get { return r_RowIndex; }
    }

    private readonly int r_ColIndex;

    public int R_ColIndex
    {
        get { return r_ColIndex; }
    } 

    private eCell m_CellSymbol = eCell.Empty;

    public eCell CellSymbol
    {
        get { return m_CellSymbol; }
        set 
        { 
            m_CellSymbol = value; 
            OnCellChange(); 
        }
    }

    public event CellChangeDelegate CellChange;

    protected virtual void OnCellChange()
    {
        if (CellChange != null)
        {
            CellChange.Invoke(this);
        }
    }

    public override string ToString()
    {
        string result = string.Empty;

        switch (m_CellSymbol)
        {
            case eCell.Empty:
                {
                    result = string.Empty;
                    break;
                }

            case eCell.X:
                {
                    result = "X";
                    break;
                }

            case eCell.O:
                {
                    result = "O";
                    break;
                }
        }

        return result;
    }

    public Cell(int i_Row, int i_Col)
    {
        r_RowIndex = i_Row;
        r_ColIndex = i_Col;
    }

    public enum eCell
    {
        X,
        O,
        Empty
    }
}